﻿@model IEnumerable<trangbaocao.Models.FuelStationsModel>        
<!--Body-->
<div align="center" style="margin-bottom:10px;"><h1>QUẢN LÝ TIỀN ĐIỆN NHÀ TRẠM</h1></div>
<br>
<h2 align="center">THÁNG  
    <select name="thang" style="width:7%" id="thang">
        @for (int i = Convert.ToInt32(DateTime.Now.Month.ToString()); i >=1 ; i--)
        {            
            if (TempData["select_thang"] != null)
            {
                if (TempData["select_thang"].ToString() == @i.ToString())
                {
                    <option  value="@i" selected="selected">@i</option>
                }
                else
                {
                    <option  value="@i">@i</option>
                }
            }
            else
            { 
                <option  value="@i">@i</option>
            }
        }       
    </select>
    NĂM @DateTime.Now.Year.ToString()
</h2>
<div class="container_12">
    <div class="grid_12">
        <!-- Notification boxes -->
        @if (TempData["msg"] != null)
        {                            
            <span class="notification n-success">@TempData["msg"]</span>
        }
        @if (TempData["error"] != null)
        {                            
            <span class="notification n-error">@TempData["error"]</span>
        }  
        @using (Html.BeginForm("FindFuelStations", "Fuel", FormMethod.Post, new { id = "FindFuelStations", name = "FindFuelStations" }))
        {
            <input type="hidden" name="thang_hidden" id="thang_hidden" />  
            <div style="padding-left:5px; margin-bottom:5px; text-align:left; width:40%">
                   <lable style="margin-right:3px">Trung tâm: </lable>
                    @if (ViewBag.trungtam_id != null)
                    {                              
                        @Html.DropDownList("main_stations_id", ViewBag.trungtam_id as SelectList, "---Chọn trung tâm---")   
                            
                    }
            </div>
            <div class="bottom-spacing">
                
                Nhà trạm: 
                <select name="select_option" style="width:22.3%; margin-left:6px">
                    <option value="stations.name"  @(ViewBag.find_selectbox == "stations.name" ? "selected" : "") >Tên nhà trạm</option>                    
                </select>
                <input type="text" class="input-short" name="timkiem" value="@ViewBag.find_textbox" style="width:15%"/>
                <input class="submit-green" type="button" onclick="submitForm()" value="Tìm kiếm"  style="width:8.5%"/>                
            </div> 
        }      
            <!-- Example table -->  
        @using (Html.BeginForm("CheckedAction", "Stations", FormMethod.Post, new { id = "CheckedAction", name = "CheckedAction" }))
        {                     
            <div class="module">
                <h2><span>@*Sample table*@</span></h2>                    
               @* <div class="module-table-body">
                    <table id="myTable" class="tablesorter">*@
                    <div class="module-table-body">
                        <div class="scrolling" style="height:400px">
                            <div class="data-table" style="width:140%">
                                <table id="myTable" class="tablesorter">
                                    <thead>
                                        <tr>
                                            <th style="width:5%;">STT</th> 
                                            <th style="width:6%;">Thêm</th>
                                            <th style="width:5%;">Sửa</th>
                                            <th style="width:15%;">Tên nhà trạm</th>
                                            <th style="width:13%;">Tiền điện tháng</th>
                                            <th style="width:13%;">Ngày cập nhật</th>
                                            <th style="width:15%;">Trung tâm</th>
                                            <th style="width:13%;">Địa chỉ</th>
                                            <th>Ghi chú</th>
                                        </tr>
                                    </thead>
                                 <tbody>
                        @{int stt = 0;}
                        @foreach (var item in Model)
                        {
                            stt++;
                            <tr>
                                <td class="align-center">@stt</td>
                                                                
                                @if (item.thang != null && Convert.ToInt32(item.thang) == Convert.ToInt32(ViewBag.thang))
                                { 
                                    <td></td>
                                    @*<td><a style="color:Red" href="@Url.Action("Stations_Detail_Index", "Fuel", new { stations_id = item.stations_id, thang = ViewBag.thang })">Đã cập nhật</a></td>*@
                                    <td align="right"><a style="color:Red" href="@Url.Action("Fuel_Stations_Update", "Fuel", new { id=item.id })"><img src="@Url.Content("~/Content/Body/Images/pencil.gif")" width="16" height="16" title="Đã cập nhật" /></a></td>                                    
                                }
                                else
                                {                                    
                                    <td class="align-center">
                                         <a onclick="SendValue(@item.stations_id)" target="_blank" style="cursor:pointer" title="Cập nhật thông tin"><img src="@Url.Content("~/Content/Body/Images/plus-small.gif")"  width="16" height="16" alt="edit" /></a>
                                    </td>
                                    <td>@*<font color="gray">Chưa cập nhật</font>*@
                                        <img src="@Url.Content("~/Content/Body/Images/Body_Images/sua.gif")" width="16" height="16" title="Chưa cập nhật" />
                                    </td>
                                    
                                }                                
                                <td> @Html.DisplayFor(modelItem => item.name)</td>
                                <td> @Html.DisplayFor(modelItem => item.tong_tien)</td>
                                <td> @Html.DisplayFor(modelItem => item.ngay_nhap)</td>
                                <td> @Html.DisplayFor(modelItem => item.ten_trung_tam)</td>
                                <td> @Html.DisplayFor(modelItem => item.dia_chi)</td>
                                <td> @Html.DisplayFor(modelItem => item.ghi_chu)</td>
                            </tr>
                        }   
                        </tbody>
                    </table>
                    </div></div>
                    <div class="pager" id="pager">
                        <div>
                        <img class="first" src="@Url.Content("~/Content/Body/Images/arrow-stop-180.gif")"  alt="first"/>
                        <img class="prev" src="@Url.Content("~/Content/Body/Images/arrow-180.gif")" alt="prev"/> 
                        <input type="text" class="pagedisplay input-short align-center"/>
                        <img class="next" src="@Url.Content("~/Content/Body/Images/arrow.gif")" alt="next"/>
                        <img class="last" src="@Url.Content("~/Content/Body/Images/arrow-stop.gif")" alt="last"/>
                        <select class="pagesize input-short align-center">
                            <option value="20" selected="selected">20</option>
                            <option value="30">30</option>
                            <option value="40">40</option>
                        </select>
                        </div>
                    </div>
                   
                    <div style="clear: both"></div>
                </div> <!-- End .module-table-body -->
            </div> <!-- End .module --> 
        }                                                                    
	</div> <!-- End .grid_12 -->            
    <div style="clear:both;"></div>            
</div> <!-- End .container_12 -->
<!----------------------------------------------------------------->
<script language="javascript" type="text/javascript">
    function submitForm() {
        document.getElementById('thang_hidden').value = document.getElementById('thang').value;
        document.getElementById("FindFuelStations").submit();
    }
    function SendValue(stations_id) {
        window.location.href = '@Url.Action("FuelStationsEdit", "Fuel")/' + '?id=' + stations_id + '&thang=' + document.getElementById('thang').value;
    }
</script>
<script type="text/javascript">
    $("#thang").change(function () {
        document.getElementById('thang_hidden').value = this.value;
        $('#FindFuelStations').submit();
    });
</script>

    

           

	